Experiment log explorer


In [1]:
%matplotlib inline
import cPickle as pickle
from IPython.html.widgets import interact, IntSliderWidget, DropdownWidget
from IPython.display import display, HTML

import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
from path_helpers import path

# Load experiment log data into `log` variable.
log_root = path('.').abspath()
log_path = log_root.joinpath('data')
log = log_path.pickle_load()
print 'Read log data from: %s' % log_path

# Create widgets that we'll display below to navigate log data.
def index_selected(name, index):
    dropdown.values = dict([(k, pickle.loads(v))
                            for k, v in log.data[index].iteritems()])
    
index_widget = IntSliderWidget(min=0, max=len(log.data) - 1)
index_widget.value = index_widget.min
# Update the plugin dropdown list whenever log index is changed.
index_widget.on_trait_change(index_selected, 'value')

dropdown = DropdownWidget(label='Plugin')
index_selected('value', index_widget.value)


[interfaces] <_MainThread(MainThread, started 139882913400640)>
Read log data from: /home/christian/.microdrop/devices/DMF-90-pin-array/logs/551/data

Explore

log.data is a list containing log data for each step. Note that the first entry (i.e., at index 0) does not correspond to a step, but instead contains details about hardware and software versions used for the experiment.

Each log entry contains a dictionary mapping each plugin name to its corresponding data for the step.

The data for each plugin is serialized using the Python pickle library. To load the step data for plugin, we can "unpickle" the corresponding dictionary entry.

For example, the interactive demo below can be used to load and display the data for each log entry by plugin name. Drag the slider to change the entry index.


In [2]:
import pprint


def summarize(data):
    summary = pprint.pformat(data)
    if len(summary) > 1000:
        summary = summary[:1000] + '...'
    return summary
    

def display_plugin_names(index=0):
    data_i = log.data[index]
    for plugin_name, plugin_pickled_data in data_i.iteritems():
        display(HTML('<h2>%s</h2>' % plugin_name))
        plugin_data = pickle.loads(plugin_pickled_data)
        print summarize(plugin_data)
    
    
interact_function = interact(display_plugin_names, index=(0, len(log.data) - 1))


core

{'control board hardware version': '2.1',
 'control board name': 'Arduino DMF Controller',
 'control board serial number': 2,
 'control board software version': '1.0.65-async-feedback',
 'i2c devices': {10: '?',
                 32: 'HV Switching Board v2.1 (Firmware v0.2.54-pwm, S/N 4294967295)'},
 'start time': 1431358960.857258}

Select

We saw above how to navigate through summaries of the experiment log data, but we can also select data for further analysis.

Using the widgets below, the data for a particular plugin at a chosen log index may be chosen. The data is then available through the value attribute of the dropdown variable.


In [3]:
def display_data(plugin_data=None):
    print summarize(plugin_data)
    return plugin_data

display(index_widget)
interact(display_data, plugin_data=dropdown)
pass


{'control board hardware version': '2.1',
 'control board name': 'Arduino DMF Controller',
 'control board serial number': 2,
 'control board software version': '1.0.65-async-feedback',
 'i2c devices': {10: '?',
                 32: 'HV Switching Board v2.1 (Firmware v0.2.54-pwm, S/N 4294967295)'},
 'start time': 1431358960.857258}

In [4]:
dropdown.value


Out[4]:
{'control board hardware version': '2.1',
 'control board name': 'Arduino DMF Controller',
 'control board serial number': 2,
 'control board software version': '1.0.65-async-feedback',
 'i2c devices': {10: '?',
  32: 'HV Switching Board v2.1 (Firmware v0.2.54-pwm, S/N 4294967295)'},
 'start time': 1431358960.857258}